/*
 * GenericInstruction.java
 * 
 * last update: 01.02.2010 by Florea Mihai
 * 
 * author:	Alec(panovici@elcom.pub.ro)
 * 			Florea Mihai(florea.mihai@gmail.com)
 * 
 * Obs: Am adaugat @SuppressWarnings("serial").
 */

package engine;

/**
 * This is a placeholder for a runtime generated action
 * (such as delayed value updates in monitors). An
 * Executable can be plugged into a GenericInstruction
 * so it can be scheduled at a later time.
 */

@SuppressWarnings("serial")
class GenericInstruction extends Instruction{

	/**
	 * 
	 */
	Executable target;
	int state;

	public GenericInstruction (Executable target) {
		this.target = target;
	}

	public String toString(){
		return target.toString();
	}

	public void execute ()
	throws InterpretTimeException, SimulationStoppedException
	{
		target.execute();
		state = 1;
		/*    if (next != null) next.execute();
          next = null;*/
	}

	public Instruction next() {
		if (state == 1) {
			state = 0;
			Instruction tmp = next;
			next = null;
			return tmp;
		}
		return next;
	}
}

